﻿using System;
using System.Collections.Generic;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using Tinter.Application.Modules.Finance.DTOs;
using Tinter.Application.Modules.Finance.Services;
using Tinter.Common.Pagination;
using Tinter.Common.TypeMappers;
using Tinter.Infrastructure.Data.Modules.Finance;
using Tinter.Infrastructure.Data.UnitOfWork;
using Tinter.Models;
using Tinter.Models.Modules.Finance;

namespace Tinter.Application.Tests
{
    /// <summary>
    ///This is a test class for FinanceAppServiceTest and is intended
    ///to contain all FinanceAppServiceTest Unit Tests
    ///</summary>
    [TestClass()]
    public class FinanceAppServiceTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        #region Fields

        private IMainUnitOfWork uow = new TinterEntities();
        private ITypeMapper typeMapper = new TypeMapper(new TypeMapSpecContainer[] { new FinanceTypeMapSpecContainer() });

        #endregion

        /// <summary>
        ///A test for FinanceAppService Constructor
        ///</summary>
        [TestMethod()]
        public void FinanceAppServiceConstructorTest()
        {
            // Arrange
            IExpenseProjectRepository expenseProjectRepository = new ExpenseProjectRepository(uow);

            // Act
            FinanceAppService target = new FinanceAppService(expenseProjectRepository, typeMapper);

            // Assert
            Assert.IsNotNull(target);
        }

        /// <summary>
        ///A test for AddExpenseProject
        ///</summary>
        [TestMethod()]
        public void AddExpenseProjectTest()
        {
            // Arrange
            IExpenseProjectRepository expenseProjectRepository = new ExpenseProjectRepository(uow);
            FinanceAppService target = new FinanceAppService(expenseProjectRepository, typeMapper);
            MyExpenseProjectDto projectDto = new MyExpenseProjectDto() { ProjectName = "TestProject1" };
            MyExpenseProjectDto expected = projectDto;
            MyExpenseProjectDto actual;

            // Act
            actual = target.AddExpenseProject(projectDto);

            // Assert
            Assert.AreEqual(expected.ProjectName, actual.ProjectName);
        }

        /// <summary>
        ///A test for AddExpense
        ///</summary>
        [TestMethod()]
        public void AddExpenseTest()
        {
            IExpenseProjectRepository expenseProjectRepository = null; // TODO: Initialize to an appropriate value
            FinanceAppService target = new FinanceAppService(expenseProjectRepository, typeMapper); // TODO: Initialize to an appropriate value
            MyExpenseDto myExpenseDto = null; // TODO: Initialize to an appropriate value
            MyExpenseDto expected = null; // TODO: Initialize to an appropriate value
            MyExpenseDto actual;
            actual = target.AddExpense(myExpenseDto);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for FindExpenses
        ///</summary>
        [TestMethod()]
        public void FindExpensesTest()
        {
            IExpenseProjectRepository expenseProjectRepository = null; // TODO: Initialize to an appropriate value
            FinanceAppService target = new FinanceAppService(expenseProjectRepository, typeMapper); // TODO: Initialize to an appropriate value
            Guid userId = new Guid(); // TODO: Initialize to an appropriate value
            string text = string.Empty; // TODO: Initialize to an appropriate value
            int pageIndex = 0; // TODO: Initialize to an appropriate value
            int pageCount = 0; // TODO: Initialize to an appropriate value
            PagedItems<MyExpenseDto> expected = null; // TODO: Initialize to an appropriate value
            PagedItems<MyExpenseDto> actual;
            actual = target.FindExpenses(userId, text, pageIndex, pageCount);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetExpense
        ///</summary>
        [TestMethod()]
        public void GetExpenseTest()
        {
            IExpenseProjectRepository expenseProjectRepository = null; // TODO: Initialize to an appropriate value
            FinanceAppService target = new FinanceAppService(expenseProjectRepository, typeMapper); // TODO: Initialize to an appropriate value
            int expenseId = 0; // TODO: Initialize to an appropriate value
            MyExpenseDto expected = null; // TODO: Initialize to an appropriate value
            MyExpenseDto actual;
            actual = target.GetExpense(expenseId);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetExpenseProjects
        ///</summary>
        [TestMethod()]
        public void GetExpenseProjectsTest()
        {
            // Arrange
            IExpenseProjectRepository expenseProjectRepository = new ExpenseProjectRepository(uow);
            FinanceAppService target = new FinanceAppService(expenseProjectRepository, typeMapper);
            Guid userId = new Guid(); // TODO: Initialize to an appropriate value
            int pageIndex = 0;
            int pageCount = 100;
            PagedItems<MyExpenseProjectDto> expected = null; // TODO: Initialize to an appropriate value
            PagedItems<MyExpenseProjectDto> actual;

            // Act
            actual = target.GetExpenseProjects(userId, pageIndex, pageCount);

            // Assert
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetExpensesByProject
        ///</summary>
        [TestMethod()]
        public void GetExpensesByProjectTest()
        {
            IExpenseProjectRepository expenseProjectRepository = null; // TODO: Initialize to an appropriate value
            FinanceAppService target = new FinanceAppService(expenseProjectRepository, typeMapper); // TODO: Initialize to an appropriate value
            Guid projectId = new Guid(); // TODO: Initialize to an appropriate value
            int pageIndex = 0; // TODO: Initialize to an appropriate value
            int pageCount = 0; // TODO: Initialize to an appropriate value
            PagedItems<MyExpenseDto> expected = null; // TODO: Initialize to an appropriate value
            PagedItems<MyExpenseDto> actual;
            actual = target.GetExpensesByProject(projectId, pageIndex, pageCount);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetExpensesByRange
        ///</summary>
        [TestMethod()]
        public void GetExpensesByRangeTest()
        {
            IExpenseProjectRepository expenseProjectRepository = null; // TODO: Initialize to an appropriate value
            FinanceAppService target = new FinanceAppService(expenseProjectRepository, typeMapper); // TODO: Initialize to an appropriate value
            var userId = new Guid(); // TODO: Initialize to an appropriate value
            var fromUtc = new DateTime(); // TODO: Initialize to an appropriate value
            var toUtc = new DateTime(); // TODO: Initialize to an appropriate value
            int pageIndex = 0; // TODO: Initialize to an appropriate value
            int pageCount = 0; // TODO: Initialize to an appropriate value
            PagedItems<MyExpenseDto> expected = null; // TODO: Initialize to an appropriate value
            PagedItems<MyExpenseDto> actual;
            actual = target.GetExpensesByRange(userId, fromUtc, toUtc, pageIndex, pageCount);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for RemoveExpense
        ///</summary>
        [TestMethod()]
        public void RemoveExpenseTest()
        {
            IExpenseProjectRepository expenseProjectRepository = null; // TODO: Initialize to an appropriate value
            FinanceAppService target = new FinanceAppService(expenseProjectRepository, typeMapper); // TODO: Initialize to an appropriate value
            int expenseId = 0; // TODO: Initialize to an appropriate value
            target.RemoveExpense(expenseId);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for SaveExpense
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Tinter.Application.dll")]
        public void SaveExpenseTest()
        {
            PrivateObject param0 = null; // TODO: Initialize to an appropriate value
            FinanceAppService_Accessor target = new FinanceAppService_Accessor(param0); // TODO: Initialize to an appropriate value
            MyExpense expense = null; // TODO: Initialize to an appropriate value
            target.SaveExpense(expense);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for UpdateExpense
        ///</summary>
        [TestMethod()]
        public void UpdateExpenseTest()
        {
            IExpenseProjectRepository expenseProjectRepository = null; // TODO: Initialize to an appropriate value
            FinanceAppService target = new FinanceAppService(expenseProjectRepository, typeMapper); // TODO: Initialize to an appropriate value
            MyExpenseDto dtoMyExpense = null; // TODO: Initialize to an appropriate value
            target.UpdateExpense(dtoMyExpense);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
    }
}
